package com.wbcs.system.buttons;

import com.wbcs.config.component.IComponentConfigBean;
import com.wbcs.system.ReportRequest;
import com.wbcs.system.component.IComponentType;
import com.wbcs.system.component.application.report.EditableDetailReportType;
import com.wbcs.system.component.application.report.EditableListReportType;
import com.wbcs.system.component.application.report.EditableListReportType2;
import com.wbcs.util.Consts;
import com.wbcs.util.Consts_Private;

public class AddButton extends AbsEditableReportButton
{
    public AddButton(IComponentConfigBean ccbean)
    {
        super(ccbean);
    }

    @Override
	public String getButtonType()
    {
        return Consts_Private.ADD_BUTTON;
    }

    @Override
	protected String getClickEvent(ReportRequest rrequest,String paramsForGetUrl)
    {
        IComponentType reportObj=rrequest.getComponentTypeObj(ccbean,null,true);
        if(reportObj instanceof EditableListReportType)
        {
            return ((EditableListReportType)reportObj).getAddEvent();
        }else if(reportObj instanceof EditableListReportType2)
        {
            return "addNewDataRow('"+ccbean.getPageBean().getId()+"','"+ccbean.getGuid()+"')";
        }else if(reportObj instanceof EditableDetailReportType)
        {
            return "changeReportAccessMode('"+ccbean.getGuid()+"','"+Consts.ADD_MODE+"')";
        }
        
        return "";
    }
}
